#include <iostream>
using namespace std;
struct contact{
    char name[11];
    int birthday;
    char phone[18];
};
int main()
{
    int N;
     contact user[10];
     cin >> N;
     for(int i = 0; i<N; i++)
         cin>>user[i].name >>user[i].birthday >> user[i].phone;
    while(true)
    {
        bool bIfSwap = false;
        for(int i = 0; i<N-1; i++)
        {
            if(user[i].birthday > user[i+1].birthday)
            {
                bIfSwap = true;
                contact temp = user[i];
                user[i] = user[i + 1];
                user[i+1] = temp;
            }
        }
        if(!bIfSwap)
            break;
    }
    
     for(int i = 0; i<N; i++)
         cout<<user[i].name <<" " << user[i].birthday <<" " << user[i].phone<<endl;
}